package com.andryyu.learn.ui

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.andryu.base.entity.LearnHeaderEntity
import com.andryu.base.ui.fragment.BaseFragment
import com.andryu.learn.databinding.FragmentAlgPageBinding
import com.andryyu.learn.adapter.LearnHeaderAdapter
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import javax.inject.Named

@AndroidEntryPoint
class AlgPageFragment: BaseFragment() {

    private var _binding : FragmentAlgPageBinding?= null
    private val binding get() = _binding!!

    @Inject
    @Named("AlgorithmList")
    lateinit var mDataList: MutableList<LearnHeaderEntity<*>>
    private lateinit var mAdapter: LearnHeaderAdapter

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        _binding = FragmentAlgPageBinding.inflate(inflater, container,false)
        return binding.root
    }


    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        binding.rvAlgPage.layoutManager = LinearLayoutManager(context)
        mAdapter = LearnHeaderAdapter(mDataList)
        binding.rvAlgPage.adapter = mAdapter
    }


    override fun onDestroy() {
        super.onDestroy()
        _binding = null
    }
}